/*
 *  gradientScene.h
 *  opencvExample
 *
 *  Created by 真鍋 大度 on 11/03/02.
 *  Copyright 2011 Rhizomatiks. All rights reserved.
 *
 */
#pragma once
#include "ofMain.h"
#include "basePattern.h"

class gradientScene : public basePattern{
public:
	void setup(){		
		allocate();
		xGap = 25;		
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				unsigned char tmpval;		
				if (j < xGap) {
					tmpval = maxGray -( (float)j*j ) / ( (float)(xGap - 1)*(xGap - 1) ) * maxGray;
				}else {
					tmpval = 0;
				}					
				
				int px = j;
				
				if (i % 2 == 1) {
					px = w - 1 - j;
				}else {
					px = j;
				}

				currentColorPixels[(i*w+ px)*3 + 0] = tmpval;
				currentColorPixels[(i*w+ px)*3 + 1] = tmpval;
				currentColorPixels[(i*w+ px)*3 + 2] = tmpval;		
			}
		}
	}
	void update(){
		currentColorImage.setFromPixels(currentColorPixels, w, h);	
		count++;
	}
	void setupWhenPatternChanged(){
		count = 0;
	}
	int count;
	int xGap;
	
};

